package com.lvhx.springboot.springbatch.sharedata;

import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.RepeatStatus;

/**
 * @auther 吕宏旭
 * @date 2019/9/5 15:05
 */
public class SetDataTasklet implements Tasklet{
    @Override
    public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {

        ExecutionContext executionContext = chunkContext.getStepContext()
                .getStepExecution()
                .getJobExecution().getExecutionContext();

        executionContext.putString("username","linux");
        System.out.println("set data tasklet.");

        return RepeatStatus.FINISHED;
    }
}
